package org.jupiter.blog.service.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.jupiter.blog.api.domain.JupiterPermissionUrl;
import org.jupiter.blog.api.domain.PermissionUrlResourceInfo;

import java.util.List;

@Mapper
public interface JupiterPermissionUrlMapper {

    int insert(JupiterPermissionUrl permissionUrl);

    JupiterPermissionUrl selectByUuid(@Param("uuid") String uuid);

    List<JupiterPermissionUrl> selectAll();

    int updateByUuidSelective(JupiterPermissionUrl permissionUrl);

    int deleteByUuid(@Param("uuid") String uuid);

    List<JupiterPermissionUrl> selectByPage(
            @Param("permissionUuid") String permissionUuid,
            @Param("urlResourceUuid") String urlResourceUuid,
            @Param("offset") int offset,
            @Param("limit") int limit
    );

    long countByQuery(
            @Param("permissionUuid") String permissionUuid,
            @Param("urlResourceUuid") String urlResourceUuid
    );

    List<JupiterPermissionUrl> selectByPermissionUuid(@Param("permissionUuid") String permissionUuid);

    List<JupiterPermissionUrl> selectByUrlResourceUuid(@Param("urlResourceUuid") String urlResourceUuid);

    JupiterPermissionUrl selectByPermissionAndUrlResource(
            @Param("permissionUuid") String permissionUuid,
            @Param("urlResourceUuid") String urlResourceUuid
    );

    int deleteByPermissionUuid(@Param("permissionUuid") String permissionUuid);

    int deleteByUrlResourceUuid(@Param("urlResourceUuid") String urlResourceUuid);

    int batchInsert(@Param("list") List<JupiterPermissionUrl> permissionUrls);

    int batchDeleteByPermissionUuid(@Param("permissionUuid") String permissionUuid, @Param("urlResourceUuids") List<String> urlResourceUuids);

    /**
     * 查询权限与URL资源的关联关系，包含权限和URL资源的详细信息
     * 用于权限初始化
     */
    List<PermissionUrlResourceInfo> selectPermissionUrlResourceInfo();
}
